Skip to content

feat(nuts): add update-nuts and verify-nuts commands#19463

Open
maurelian wants to merge 31 commits intodevelopfrom
feat/nut-update-verify
Open

feat(nuts): add update-nuts and verify-nuts commands#19463
maurelian wants to merge 31 commits intodevelopfrom
feat/nut-update-verify

Conversation

@maurelian
Copy link
Copy Markdown
Contributor

@maurelian maurelian commented Mar 10, 2026

Summary

Here we establish a workflow for canonicalizing a bundle for a given fork.

New commands:

  • just nut-snapshot-for <fork> — snapshots current-upgrade-bundle.json as a fork's NUT bundle and updates fork_lock.toml with the hash and commit.
  • just nut-provenance-verify <fork> — for a given fork in the lock file, verifies that bundle hash matches the bundle as generated from the recorded commit. Runs in CI only on changed hashes.

Modifications to existing commands:

  • Extends fork_lock.toml schema with a commit field to track which commit produced each bundle
  • Extends just check-nut-locks to ensure that commits in the lockfile are available in the git history.

Test plan

  • just nut-snapshot-for karst — copies bundle, updates lock with hash + commit
  • just check-nut-locks — passes with new commit field in schema
  • just nut-provenance-verify karst — passes (hash matches lock)
  • Manually edit the bundle → just check-nut-locks fails (hash mismatch) (broken commit/job demo)
  • Manually edit the commit → just check-nut-locks fails (commit not found in history) (broken commit/job demo)
  • just nut-provenance-verify karst after modifying the bundle → fails (regenerated bundle differs)

@maurelian maurelian requested a review from a team as a code owner March 10, 2026 00:58
@wiz-inc-a178a98b5d
Copy link
Copy Markdown

wiz-inc-a178a98b5d bot commented Mar 10, 2026

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities -
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings -
Software Management Finding Software Management Findings -
Total -

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.9%. Comparing base (cba7aba) to head (0da7f52).
⚠️ Report is 11 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #19463      +/-   ##
===========================================
+ Coverage     75.6%    75.9%    +0.2%     
===========================================
  Files          195      684     +489     
  Lines        11343    73097   +61754     
===========================================
+ Hits          8581    55500   +46919     
- Misses        2618    17453   +14835     
  Partials       144      144              
Flag Coverage Δ
cannon-go-tests-64 66.4% <ø> (ø)
contracts-bedrock-tests 80.7% <ø> (ø)
unit 75.9% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 489 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@maurelian maurelian force-pushed the feat/nut-update-verify branch from 3665df7 to f528e73 Compare April 1, 2026 19:18
@maurelian maurelian requested a review from a team as a code owner April 1, 2026 19:18
@maurelian maurelian requested a review from Inphi April 1, 2026 19:18
maurelian and others added 6 commits April 1, 2026 16:23
Generates a fresh NUT bundle from contracts and snapshots it to the
fork-specific location, updating fork_lock.toml with hash and commit.
Let the caller generate the bundle separately. update-nuts should
only snapshot and lock what already exists.
Covers generation, snapshotting, verification, CI checks,
and the process for adding a new fork's bundle.
Moves the duplicated struct and lock file read/write logic into a
shared package, addressing review feedback.
@maurelian maurelian force-pushed the feat/nut-update-verify branch from f528e73 to 4bf25a6 Compare April 1, 2026 20:23
Wiz SAST flagged 0644 as overly permissive for generated bundle files.
Prevents accidental overwrites of finalized NUT bundles. A `locked`
boolean in fork_lock.toml gates update-nuts and CI enforcement.
check-nut-locks -> nut-lock-check
update-nuts -> nut-snapshot-for
verify-nuts -> nut-provenance-verify
The original bundle predated the snapshot workflow, so the commit field
couldn't be verified. Regenerated from current contracts.
@maurelian maurelian requested a review from a team as a code owner April 1, 2026 21:43
The current-upgrade-bundle.json and nut-bundle-check are contracts-bedrock
concerns, not relevant to the op-core/nuts package.
Hash verification and code review are sufficient protection.
The locked field, base-branch comparison, and update guard
added unnecessary complexity.
Update fork_lock.toml header with reviewer guidance. Add
nut-provenance-verify to CI, gated on op-core/nuts/ changes.
Compare each fork's hash against origin/develop to skip unchanged ones.
nut-snapshot-for now records git merge-base HEAD origin/develop instead
of HEAD, so the commit persists after squash-merge. check-nut-locks
verifies the commit is an ancestor of origin/develop.
refactor(nuts): use multiline strings in WriteLockFile
Extract validateEntry for testability. Tests cover: matching hash,
hash mismatch, empty commit, and modified bundle detection.
Inject bundleGenerator to test the worktree checkout and comparison
flow without requiring forge. Covers matching, mismatched, and
generator-modified bundle scenarios.
@maurelian maurelian force-pushed the feat/nut-update-verify branch from 8a3d102 to 0da7f52 Compare April 2, 2026 20:37
@maurelian maurelian enabled auto-merge April 3, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants